Conversation
``` @trace tessera mysin(x)=sin(x) ``` This will add an attribute with name `tessera_name` and value a stringattr with the function name (`"mysin"`) to the generated function for mysin. (note that you need `@code_hlo optimize=false` to see this attribute, otherwise it is inlined.)
3efbed4 to
d862e5a
Compare
d862e5a to
6804c97
Compare
Now a custom |
| end | ||
|
|
||
| # Get function name from expression | ||
| fname_expr = func_expr.args[1] |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| fname_expr = func_expr.args[1] |
|
|
||
| return quote | ||
| # Define the function and register tessera_op | ||
| $(esc(traced_expr)) |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| $(esc(traced_expr)) |
| $(esc(fname_sym)) | ||
| end | ||
| end | ||
|
|
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
|
|
||
| function compile_call_expr(_mod, compiler, options::Dict, args...) | ||
| while length(args) > 1 | ||
| option, args = args[1], args[2:end] |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| option, args = args[1], args[2:end] |
| @noinline function call( | ||
| f, args...; location=mlir_stacktrace("call", @__FILE__, @__LINE__), tessera_op=nothing | ||
| ) | ||
|
|
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| include("serialization/Serialization.jl") | ||
|
|
||
| using .Compiler: @compile, @code_hlo, @code_mhlo, @jit, @code_xla, traced_getfield, compile | ||
| using .Compiler: @compile, @code_hlo, @code_mhlo, @jit, @code_xla, @tessera_op, traced_getfield, compile |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| using .Compiler: @compile, @code_hlo, @code_mhlo, @jit, @code_xla, @tessera_op, traced_getfield, compile | |
| using .Compiler: | |
| @compile, @code_hlo, @code_mhlo, @jit, @code_xla, @tessera_op, traced_getfield, compile |
| return 1 ./ x | ||
| end | ||
|
|
||
|
|
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| return sin.(sum(x) .+ x) | ||
| end | ||
|
|
||
|
|
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
|
|
||
| hlo2 = repr(@code_hlo optimize = false foo(x)) | ||
| @test occursin("tessera_op = \"foo\"", hlo2) | ||
| end No newline at end of file |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| end | |
| end | |
This will add an attribute with name
tessera_nameand value a stringattr with the function name ("reciprocal") to the generated MLIR function. (note that you need@code_hlo optimize=falseto see this attribute, otherwise it is inlined.)generates code containing:
(note the
tessera_nameattribute)It might be nicer to have a dedicated macro, i.e.:
I just did it this way because it was quicker to reuse some stuff.